<template>
    <div>
        <global-tables
            @changePage="handleChangePage"
            :total="total"
            @handleAllSelect="handleAllSelect"
            :list="list"
            :loading="loading"
            :columns="columns"
            :current="search.Page"
        >
            <Form :model="search" :label-width="80">
                <div class="table-top-wrap">
                    <div>
                        <div></div>
                    </div>
                    <div class="table-top-wrap-bottom">
                        <div>
                            <input type="text" class="style-input" @keyup.enter="handleSearch" v-model="search.keyword" placeholder="请输入预约人姓名" />
                            <i-input style="display:none"></i-input>
                        </div>
                        <div>
                            <Button icon="ios-search" @click="handleSearch" class="search-btn">搜索</Button>
                        </div>
                    </div>
                </div>
            </Form>
        </global-tables>
        <Modal :mask-closable="false" v-model="isModal" :title="ModalTitle" width="1100">
            <div v-if="isModal">
                <Form ref="formItem" :model="formItem" :rules="ruleValidate" :label-width="110">
                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="方式" prop="OrderType">
                                <Select v-model="formItem.OrderType">
                                    <Option :value="'1'" :key="1">陪诊</Option>
                                    <Option :value="'2'" :key="2">送药</Option>
                                    <Option :value="'3'" :key="3">护理</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="服务项目" prop="ProName">
                                <Select v-model="formItem.ProName">
                                    <Option
                                        v-for="item in ServiceList"
                                        :value="item.ProName"
                                        :key="item.ID"
                                        @click.native="handleServiceList(item)"
                                    >{{ item.ProName }}</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="预约人姓名" prop="UserName">
                                <i-input v-model="formItem.UserName" placeholder="请输入预约人姓名"></i-input>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="预约电话" prop="UserPhone">
                                <i-input v-model="formItem.UserPhone" placeholder="请输入预约电话" type="number" :maxlength="11"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="用户年龄" prop="UserAge">
                                <i-input v-model="formItem.UserAge" placeholder="请输入用户年龄" type="number"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="性别" prop="UserSex">
                                <Select v-model="formItem.UserSex">
                                    <Option :value="'true'" :key="'1'">男</Option>
                                    <Option :value="'false'" :key="'2'">女</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                    </Row>

                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="出发地址" prop="FromAddress">
                                <i-input v-model="formItem.FromAddress" placeholder="请输入出发地址"></i-input>
                                <!-- <Cascader :data="cityList" v-model="formItem.FromAddress" placeholder="请选择城市" @on-change="setCityName"></Cascader> -->
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="目的地址" prop="ToAddress">
                                <i-input v-model="formItem.ToAddress" placeholder="请输入目的地址"></i-input>
                                <!-- <Cascader :data="cityList" v-model="formItem.ToAddress" placeholder="请选择城市"></Cascader> -->
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="预约开始时间" prop="BeginTime">
                                <DatePicker type="date" v-model="formItem.BeginTime" placeholder="请选择日期" style="width:100%"></DatePicker>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="预约结束时间" prop="EndTime">
                                <DatePicker type="date" v-model="formItem.EndTime" placeholder="请选择日期" style="width: 100%"></DatePicker>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="接单门店" prop="ShopName">
                                <Select v-model="formItem.ShopName" placeholder="请选择接单门店">
                                    <Option
                                        v-for="item in shopList"
                                        :value="item.ShopName"
                                        :key="item.ID"
                                        @click.native="handleshopList(item)"
                                    >{{ item.ShopName }}</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="指派人员" prop="ServiceName">
                                <Select v-model="formItem.ServiceName" placeholder="请选择指派人员">
                                    <Option
                                        v-for="item in ServiceNameList"
                                        :value="item.RealName"
                                        :key="item.ID"
                                        @click.native="handleServiceNameList(item)"
                                    >{{ item.RealName }}</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="基础服务费" prop="Money_Service">
                                <i-input v-model="formItem.Money_Service" placeholder="请输入基础服务费" type="number"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="用车费" prop="Money_Car">
                                <i-input v-model="formItem.Money_Car" placeholder="请输入用车费" type="number"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="超出距离加收" prop="Money_DistanceOut">
                                <i-input v-model="formItem.Money_DistanceOut" placeholder="请输入超出距离加收费" type="number"></i-input>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="超时费用" prop="Money_TimeOut">
                                <i-input v-model="formItem.Money_TimeOut" placeholder="请输入超时费用" type="number"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="特殊费用" prop="Money_Special">
                                <i-input v-model="formItem.Money_Special" placeholder="请输入特殊费用" type="number"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="费用总额" prop="Money_Total">
                                <i-input v-model="formItem.Money_Total" placeholder="请输入费用总额" type="number"></i-input>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="状态" prop="State">
                                <Select v-model="formItem.State">
                                    <Option :value="'0'" :key="0">待确认</Option>
                                    <Option :value="'1'" :key="1">已确认</Option>
                                    <Option :value="'2'" :key="2">已付款</Option>
                                    <Option :value="'3'" :key="3">已完成</Option>
                                    <Option :value="'4'" :key="4">已取消</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="是否用车" prop="NeedCar">
                                <Select v-model="formItem.NeedCar">
                                    <Option :value="'true'" :key="'是'">是</Option>
                                    <Option :value="'false'" :key="'否'">否</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="指派确认时间" prop="ConfirmTime">
                                <DatePicker type="date" v-model="formItem.ConfirmTime" placeholder="请选择日期" style="width:100%"></DatePicker>
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="完成时间" prop="FinishTime">
                                <DatePicker type="date" v-model="formItem.FinishTime" placeholder="请选择日期" style="width:100%"></DatePicker>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 8}">
                            <FormItem label="到达现场时间" prop="ArriveTime">
                                <DatePicker type="date" v-model="formItem.ArriveTime" placeholder="请选择日期" style="width:100%"></DatePicker>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 24}">
                            <FormItem label="病情描述" prop="SickName">
                                <i-input type="textarea" v-model="formItem.SickName" placeholder="请输入病情"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 24}">
                            <FormItem label="特殊情况" prop="Special">
                                <i-input type="textarea" v-model="formItem.Special" placeholder="请输入备注"></i-input>
                            </FormItem>
                        </i-col>
                        <i-col :lg="{ span: 24}">
                            <FormItem label="具体要求说明" prop="Remark">
                                <i-input type="textarea" v-model="formItem.Remark" placeholder="请输入备注"></i-input>
                            </FormItem>
                        </i-col>
                    </Row>
                </Form>
            </div>
            <div slot="footer">
                <Button size="large" @click="handleClose">取消</Button>
                <Button type="primary" size="large" @click="handleSubmit('formItem')">确定</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
/**
 * 公司列表
 */
import { cyclicRouting, getdate } from '@/util';
// import cityListJson from '@/config/citySecondLevel.js';
import { getModulePermission } from '@/api/user';
import {
    getTablesList,
    getItemInfo,
    GetServiceList,
    GetPCDList,
    GetShopList,
    GetShopUserList
} from './service';
import GlobalTables from '@/components/GlobalTables';
export default {
    name: 'OrganizationCompany',
    components: {
        GlobalTables
    },
    data() {
        /* 城市校验 由于级联校验存在问题采用次方法 */
        // const validatePass = (rule, value, callback) => {
        //     if (this.cityValue.length < 1) {
        //         callback(new Error('请选择城市'));
        //     } else {
        //         callback();
        //     }
        // };
        const valiShopName = (rule, value, callback) => {
            if (this.formItem.ShopName == '') {
                callback(new Error('请选择接单门店'));
            } else {
                callback();
            }
        };
        // const valiServiceName = (rule, value, callback) => {
        //     if (!this.formItem.ServiceName || this.formItem.ServiceName == '') {
        //         callback(new Error('请选择指派人员'));
        //     } else {
        //         callback();
        //     }
        // };

        return {
            list: [],
            cityList: [],
            cityValue: [],
            cityName: [],
            itemId: 0,
            ServiceList: [],
            shopList: [],
            ServiceNameList: [],
            allSelectArr: null,
            loading: true,
            total: 0,
            formItem: this.initFormItem(),
            ruleValidate: {
                OrderType: [
                    {
                        required: true,
                        message: '请选择就医方式',
                        trigger: 'change'
                    }
                ],
                ProName: [
                    {
                        required: true,
                        message: '请选择服务项目',
                        trigger: 'change'
                    }
                ],
                UserName: [
                    {
                        required: true,
                        message: '请输入预约人姓名',
                        trigger: 'change'
                    }
                ],
                UserPhone: [
                    {
                        required: true,
                        message: '请输入预约电话',
                        trigger: 'change'
                    }
                ],
                UserAge: [
                    {
                        required: true,
                        message: '请输入用户年龄',
                        trigger: 'change'
                    }
                ],
                FromAddress: [
                    {
                        required: true,
                        message: '请输入出发地址',
                        trigger: 'change'
                    }
                ],
                ToAddress: [
                    {
                        required: true,
                        message: '请输入目的地址',
                        trigger: 'change'
                    }
                ],
                // cityValue: [
                //     {
                //         validator: validatePass,
                //         required: true,
                //         trigger: 'change'
                //     }
                // ],
                UserSex: [
                    {
                        required: true,
                        message: '请输入联系电话',
                        trigger: 'change'
                    }
                ],
                BeginTime: [
                    {
                        required: true,
                        message: '请选择日期',
                        trigger: 'change',
                        pattern: /.+/
                    }
                ],
                EndTime: [
                    {
                        required: true,
                        message: '请选择日期',
                        trigger: 'change',
                        pattern: /.+/
                    }
                ],
                ShopName: [
                    {
                        required: true,
                        validator: valiShopName,
                        message: '请选择接单门店',
                        trigger: 'change'
                    }
                ],
                ServiceName: [
                    {
                        required: true,
                        // validator: valiServiceName,
                        message: '请选择指派人员',
                        trigger: 'change'
                    }
                ],
                Money_Service: [
                    {
                        required: true,
                        message: '请输入基础服务费',
                        trigger: 'change'
                    }
                ],
                Money_Car: [
                    {
                        required: true,
                        message: '请输入用车费',
                        trigger: 'change'
                    }
                ],
                Money_DistanceOut: [
                    {
                        required: true,
                        message: '请输入超出距离加收费用',
                        trigger: 'change'
                    }
                ],
                Money_TimeOut: [
                    {
                        required: true,
                        message: '请输入超时费用',
                        trigger: 'change'
                    }
                ],
                Money_Special: [
                    {
                        required: true,
                        message: '请输入特殊费用',
                        trigger: 'change'
                    }
                ],
                Money_Total: [
                    {
                        required: true,
                        message: '请输入费用总额',
                        trigger: 'change'
                    }
                ],
                State: [
                    {
                        required: true,
                        message: '请选择状态',
                        trigger: 'change'
                    }
                ],
                NeedCar: [
                    {
                        required: true,
                        message: '请选择是否用车',
                        trigger: 'change'
                    }
                ],
                ConfirmTime: [
                    {
                        required: true,
                        message: '请选择日期',
                        trigger: 'change',
                        pattern: /.+/
                    }
                ],
                FinishTime: [
                    {
                        required: true,
                        message: '请选择日期',
                        trigger: 'change',
                        pattern: /.+/
                    }
                ],
                ArriveTime: [
                    {
                        required: true,
                        message: '请选择日期',
                        trigger: 'change',
                        pattern: /.+/
                    }
                ],
                SickName: [
                    {
                        required: true,
                        message: '请输入病情',
                        trigger: 'change'
                    }
                ],
                Remark: [
                    {
                        required: true,
                        message: '请输入备注',
                        trigger: 'change'
                    }
                ]
            },
            isAddBtn: false,
            isProhibit: false,
            isEdit: false,
            isModal: false,
            ModalTitle: '新建公司',
            search: {
                keyword: '',
                // ISVIP: '',
                pageindex: 1,
                pagesize: 10
            },
            columns: [
                {
                    type: 'selection',
                    width: 60,
                    align: 'center'
                },
                {
                    title: '姓名',
                    key: 'UserName',
                    width: 100
                },
                {
                    title: '性别',
                    width: 80,
                    key: 'UserSex',
                    render: (h, params) => {
                        const { UserSex } = params.row;
                        if (UserSex) {
                            return h('div', [h('span', {}, '男')]);
                        } else {
                            return h('div', [h('span', {}, '女')]);
                        }
                    }
                },
                {
                    title: '年龄',
                    key: 'UserAge',
                    width: 100
                },
                {
                    title: '电话',
                    width: 150,
                    key: 'UserPhone'
                },
                {
                    title: '服务项目',
                    key: 'ShopName'
                },

                {
                    title: '病情描述',
                    width: 200,
                    render: (h, params) => {
                        return h('div', [
                            h(
                                'Poptip',
                                {
                                    props: { placement: 'bottom' }
                                },
                                [
                                    h(
                                        'span',
                                        {
                                            style: {
                                                display: 'inline-block',
                                                width: params.column._width * 0.7 + 'px',
                                                overflow: 'hidden',
                                                textOverflow: 'ellipsis',
                                                whiteSpace: 'nowrap'
                                            }
                                        },
                                        params.row.SickName
                                    ),
                                    h(
                                        'span',
                                        {
                                            slot: 'content',
                                            style: {
                                                whiteSpace: 'normal',
                                                wordBreak: 'break-all'
                                            }
                                        },
                                        params.row.SickName
                                    )
                                ]
                            )
                        ]);
                    }
                },
                {
                    title: '出发地址',
                    width: 200,
                    render: (h, params) => {
                        return h('div', [
                            h(
                                'Poptip',
                                {
                                    props: { placement: 'bottom' }
                                },
                                [
                                    h(
                                        'span',
                                        {
                                            style: {
                                                display: 'inline-block',
                                                width: params.column._width * 0.7 + 'px',
                                                overflow: 'hidden',
                                                textOverflow: 'ellipsis',
                                                whiteSpace: 'nowrap'
                                            }
                                        },
                                        params.row.FromAddress
                                    ),
                                    h(
                                        'span',
                                        {
                                            slot: 'content',
                                            style: {
                                                whiteSpace: 'normal',
                                                wordBreak: 'break-all'
                                            }
                                        },
                                        params.row.FromAddress
                                    )
                                ]
                            )
                        ]);
                    }
                },
                {
                    title: '目的地址',
                    width: 200,
                    render: (h, params) => {
                        return h('div', [
                            h(
                                'Poptip',
                                {
                                    props: { placement: 'bottom' }
                                },
                                [
                                    h(
                                        'span',
                                        {
                                            style: {
                                                display: 'inline-block',
                                                width: params.column._width * 0.7 + 'px',
                                                overflow: 'hidden',
                                                textOverflow: 'ellipsis',
                                                whiteSpace: 'nowrap'
                                            }
                                        },
                                        params.row.ToAddress
                                    ),
                                    h(
                                        'span',
                                        {
                                            slot: 'content',
                                            style: {
                                                whiteSpace: 'normal',
                                                wordBreak: 'break-all'
                                            }
                                        },
                                        params.row.ToAddress
                                    )
                                ]
                            )
                        ]);
                    }
                },
                // {
                //     title: '资格',
                //     width: 80,
                //     key: 'ISVIP',
                //     render: (h, params) => {
                //         const { ISVIP } = params.row;
                //         if (ISVIP) {
                //             return h('div', [
                //                 h('Badge', {
                //                     props: {
                //                         status: 'warning',
                //                         text: 'VIP'
                //                     }
                //                 })
                //             ]);
                //         } else {
                //             return h('div', [
                //                 h('Badge', {
                //                     props: {
                //                         status: 'success',
                //                         text: '免费'
                //                     }
                //                 })
                //             ]);
                //         }
                //     }
                // },
                {
                    title: '状态',
                    width: 100,
                    render: (h, params) => {
                        const { State } = params.row;
                        if (State == 0) {
                            return h('div', [
                                h('Badge', {
                                    props: {
                                        status: 'processing',
                                        text: '待确认'
                                    }
                                })
                            ]);
                        } else if (State == 1) {
                            return h('div', [
                                h('Badge', {
                                    props: {
                                        status: 'processing',
                                        text: '已确认'
                                    }
                                })
                            ]);
                        } else if (State == 2) {
                            return h('div', [
                                h('Badge', {
                                    props: {
                                        status: 'processing',
                                        text: '已付款'
                                    }
                                })
                            ]);
                        } else if (State == 3) {
                            return h('div', [
                                h('Badge', {
                                    props: {
                                        status: 'processing',
                                        text: '已完成'
                                    }
                                })
                            ]);
                        } else if (State == 4) {
                            return h('div', [
                                h('Badge', {
                                    props: {
                                        status: 'error',
                                        text: '已取消'
                                    }
                                })
                            ]);
                        }
                    }
                },
                // {
                //     title: '结束时间',
                //     width: 120,
                //     key: 'EndDate',
                //     render: (h, params) => {
                //         const endtTime = new Date(params.row.EndDate).getTime();
                //         const currentTime = new Date().getTime();
                //         if (endtTime > currentTime) {
                //             return h('div', [
                //                 h(
                //                     'span',
                //                     {
                //                         props: {
                //                             size: 'small'
                //                         }
                //                     },
                //                     getdate(new Date(params.row.EndDate).getTime())
                //                 )
                //             ]);
                //         } else {
                //             return h('div', [
                //                 h(
                //                     'span',
                //                     {
                //                         props: {
                //                             size: 'small'
                //                         },
                //                         style: {
                //                             color: '#ed4014'
                //                         }
                //                     },
                //                     getdate(new Date(params.row.EndDate).getTime())
                //                 )
                //             ]);
                //         }
                //     }
                // },
                {
                    title: '创建时间',
                    width: 120,
                    key: 'CreateTime',
                    render: (h, params) => {
                        return h('div', [
                            h(
                                'span',
                                {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    }
                                },
                                getdate(new Date(params.row.CreateTime).getTime())
                            )
                        ]);
                    }
                },
                {
                    title: '操作',
                    width: 70,
                    align: 'center',
                    render: (h, params) => {
                        const { isEdit } = this;
                        return h('div', [
                            isEdit &&
                                h(
                                    'Button',
                                    {
                                        props: {
                                            type: 'primary',
                                            size: 'small'
                                        },
                                        style: {
                                            background: '#009688',
                                            border: 'none',
                                            marginRight: '5px'
                                        },
                                        on: {
                                            click: () => {
                                                this.handleBtnClick(params.row, 'edit');
                                            }
                                        }
                                    },
                                    '编辑'
                                )
                        ]);
                    }
                }
            ]
        };
    },
    methods: {
        /* 表格分页方法 */
        handleChangePage(type, page) {
            this.loading = true;
            if (type == 'page') {
                this.search.pageindex = page;
                this.getTablesListData();
            } else {
                this.search.pagesize = page;
                this.getTablesListData();
            }
        },
        /* 关闭对话框 */
        handleClose() {
            this.isModal = false;
        },
        //选择服务项目
        handleServiceList(item) {
            
            this.formItem.ProName = item.ProName;
            this.formItem.OrderItem = item.ID;
        },
        //指派门店人员
        handleServiceNameList(item) {
            this.formItem.ServiceID = item.ID;
            this.formItem.ServiceName = item.RealName;
        },
        //选择门店
        handleshopList(item) {
            
            this.formItem.ShopID = item.ID;
            this.formItem.ShopName = item.ShopName;
            this.ServiceNameList = [];
            this.formItem.ServiceName = '';
            GetShopUserList({
                SID: item.ID
            }).then(res => {
                this.ServiceNameList = res.data;
            });
        },
        /* 设置城市名称 */
        setCityName(value) {
            GetShopList({
                CID: value[1]
            }).then(res => {
                this.shopList = res.data;
            });

            //this.cityName = label;
            //
        },
        /* 提交 */
        handleSubmit(name) {
            this.$refs[name].validate(valid => {
                if (valid) {
                    let data = {
                        ...this.formItem
                    };

                    getItemInfo(data).then(res => {
                        if (res.state == 'success') {
                            this.$Message.success('操作成功');
                            this.loading = true;
                            this.isModal = false;
                            this.getTablesListData();
                        } else {
                            this.$Message.error(res.message);
                        }
                    });
                }
            });
        },
        /* 表格数据请求 */
        getTablesListData() {
            const data = this.search;
            getTablesList(data).then(res => {
                this.list = res.data.rows;
                this.loading = false;
                this.total = res.data.records;
            });
        },
        /* 表格查询 */
        handleSearch() {
            this.loading = true;
            this.getTablesListData();
        },
        /* 对话框 */
        handleBtnClick(item) {
            this.ModalTitle = '修改订单';
            this.formItem = this.initFormItem();
            this.cityValue = [];
            this.isModal = true;
            this.formItem = {
                ...item,
                ID: item.ID,
                UserSex: item.UserSex + '',
                NeedCar: item.NeedCar + '',
                Money_Car: item.Money_Car + '',
                Money_DistanceOut: item.Money_DistanceOut + '',
                Money_Service: item.Money_Service + '',
                Money_Special: item.Money_Special + '',
                Money_TimeOut: item.Money_TimeOut + '',
                Money_Total: item.Money_Total + ''
            };
            for (var i = 0; i < this.ServiceList.length; i++) {
                if (this.ServiceList[i].ID == item.OrderItem) {
                    this.formItem.OrderItem = this.ServiceList[i].ID;
                    this.formItem.ProName = this.ServiceList[i].ProName;
                }
            }
            GetShopList({ CID: item.CityID }).then(res => {
                this.shopList = res.data;
                for (var j = 0; j < res.data.length; j++) {
                    if (res.data[j].ID == item.ShopID) {
                        this.formItem.ShopName = res.data[j].ShopName;
                        this.formItem.ShopID = res.data[j].ID;
                    }
                }
            });
            GetShopUserList({ SID: item.ShopID }).then(res => {
                this.ServiceNameList = res.data;
                for (var i = 0; i < res.data.length; i++) {
                    if (res.data[i].ID == item.ServiceID) {
                        this.formItem.ServiceName = res.data[i].RealName;
                    }
                }
            });
        },
        /* 表单数据 */
        initFormItem() {
            return {
                ID: 0,
                ProName: null,
                OrderType: 1,
                OrderItem: null,
                UserName: null,
                UserPhone: null,
                UserAge: null,
                UserSex: null,
                FromAddress: null,
                ToAddress: null,
                NeedCar: null,
                BeginTime: null,
                EndTime: null,
                SickName: null,
                Special: null,
                FromProID: null,
                FromAreaID: null,
                FromCityID: null,
                Money_Service: null,
                Money_Car: null,
                Money_DistanceOut: null,
                Money_TimeOut: null,
                Money_Special: null,
                Money_Total: null,
                ShopID: null,
                ShopName: null,
                ServiceID: null,
                ServiceName: null,
                State: null,
                Remark: null,
                ConfirmTime: null,
                FinishTime: null,
                ArriveTime: null
            };
        },
        /* 复选框选中 */
        handleAllSelect(list) {
            let arr = [];
            for (let item in list) {
                arr.push(list[item].ID);
                arr.join(',');
            }
            arr = arr.join(',');
            this.allSelectArr = arr;
        }
        /* 设置城市 */
        // setCity() {
        //     this.cityList = cityListJson.list;
        // }
    },
    mounted() {
        /* 获取菜单的id */
        cyclicRouting(JSON.parse(sessionStorage.getItem('user')).menuList, this.$route, id => {
            /* 按钮权限请求 */
            getModulePermission({
                roleid: JSON.parse(sessionStorage.getItem('user')).roleid,
                moduleid: id
            }).then(res => {
                // this.setCity();

                /* 按钮权限赋值 */
                for (let item in res.data) {
                    if (res.data[item].name == 'add') {
                        this.isAddBtn = true;
                    } else if (res.data[item].name == 'onoff') {
                        this.isProhibit = true;
                    } else if (res.data[item].name == 'edit') {
                        this.isEdit = true;
                    }
                }
                /* 列表请求 */
                this.getTablesListData();
            });
        });
        GetPCDList().then(res => {
            //
            this.cityList = res.data;
        });
        GetServiceList().then(res => {
            //
            this.ServiceList = res.data;
        });
    }
};
</script>

<style>
</style>

